package com.zixi.ai.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.ollama.api.OllamaOptions;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wfg
 */
@Configuration
public class ModelConfig {
    @Bean
    public ChatModel qwenChatModel() {
        String baseUrl = "http://localhost:11434";
        String model = "qwen3:0.6b";
        ChatModel chatModel;
        OllamaApi ollamaApi = OllamaApi.builder().baseUrl(baseUrl).build();
        OllamaOptions options = new OllamaOptions();
        options.setModel(model);
        chatModel = OllamaChatModel.builder()
                .ollamaApi(ollamaApi)
                .defaultOptions(options)
                .build();
        return chatModel;
    }

    @Bean
    public ChatClient chatClient(@Qualifier("qwenChatModel") ChatModel qwenChatModel) {
        return ChatClient.builder(qwenChatModel)
                .build();
    }
}
